import logging
from logging.handlers import RotatingFileHandler


# 添加文件处理器
handler = RotatingFileHandler('log/app.log', maxBytes=10000, backupCount=3)
handler.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
logging.getLogger().addHandler(handler)